﻿using Marqdown;
using NUnit.Framework;

namespace MarkdownSharpTests
{
    [TestFixture]
    class SimpleTests2: CommonTests
    {
        private Markdown _m;
        [SetUp]
        public void SetUp()
        {
            _m = new Markdown();
        }
        protected override string Transform(string input)
        {
            return _m.Transform(input);
        }

        [Test]
        public void BulletListAfterNewline()
        {
            string input = "A bulleted list:\n- a\n+ b\n* c\n";
            string expected = "<p>A bulleted list:</p>\n\n<ul>\n<li>a</li>\n<li>b</li>\n<li>c</li>\n</ul>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void BulletListNestingHeader()
        {
            string input = "A bulleted list:\n\n- a\n a1\n #header\n a2\n+ b\n* c\n";
            string expected = "<p>A bulleted list:</p>\n\n<ul>\n<li>a\na1\n<h1>header</h1>\n\n<p>a2</p>\n</li>\n<li>b</li>\n<li>c</li>\n</ul>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void BulletListNestingBlockquote()
        {
            string input = "A bulleted list:\n\n- a\n a1\n > blockquote\n a2\n+ b\n* c\n";
            string expected = "<p>A bulleted list:</p>\n\n<ul>\n<li>a\na1\n<blockquote>\n  <p>blockquote\n  a2</p>\n</blockquote>\n</li>\n<li>b</li>\n<li>c</li>\n</ul>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }

        [Test]
        public void BulletListLooseNestingBulletList()
        {
            string input = "A bulleted list:\n\n- a\n\n - a1\n - a2\n+ b\n* c\n";

            string expected = "<p>A bulleted list:</p>\n\n<ul>\n<li><p>a</p>\n\n<ul>\n<li>a1</li>\n<li>a2</li>\n</ul></li>\n<li><p>b</p></li>\n<li><p>c</p></li>\n</ul>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void BulletListLooseNestingBulletList2()
        {
            // This test failed originally - I changed the test - now its not consistent with BulletListLooseNestingBulletList
            string input = "A bulleted list:\n\n- a\n - a1\n - a2\n+ b\n\n* c\n";

            string expected = "<p>A bulleted list:</p>\n\n<ul>\n<li><p>a\n</p>\n\n<ul>\n<li>a1</li>\n<li>a2</li>\n</ul></li>\n<li><p>b</p></li>\n<li><p>c</p></li>\n</ul>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }

        [Test]
        public void NumberListAfterNewline()
        {
            string input = "A numbered list:\n1. a\n2. b\n9. c\n";
            string expected = "<p>A numbered list:</p>\n\n<ol>\n<li>a</li>\n<li>b</li>\n<li>c</li>\n</ol>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void NumberListLooseNestingBulletList()
        {
            string input = "A numbered list:\n\n1. a\n\n - a1\n - a2\n1. b\n1. c\n";
            string expected = "<p>A numbered list:</p>\n\n<ol>\n<li><p>a</p>\n\n<ul>\n<li>a1</li>\n<li>a2</li>\n</ul></li>\n<li><p>b</p></li>\n<li><p>c</p></li>\n</ol>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void NumberListLooseNestingBulletList2()
        {
            // This test failed originally - I changed the test - now its not consistent with BulletListLooseNestingBulletList
            string input = "A numbered list:\n\n1. a\n - a1\n - a2\n1. b\n\n1. c\n";
            string expected = "<p>A numbered list:</p>\n\n<ol>\n<li><p>a\n</p>\n\n<ul>\n<li>a1</li>\n<li>a2</li>\n</ul></li>\n<li><p>b</p></li>\n<li><p>c</p></li>\n</ol>\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }

        [Test]
        public void HorizontalRuleLeadingSpaces()
        {
            string input = " * * *\n\n  ***\n\n   *****\n\n    - - -\n\n---------------------------------------\n\n";
            string expected = "<hr />\n\n<hr />\n\n<hr />\n\n<hr />\n\n<hr />\n";

            string actual = Transform(input);

            Assert.AreEqual(expected, actual);
        }

    }
}
